//
//  PraiseAndCommentView.m
//  TravelFirst
//
//  Created by lanou on 15/9/19.
//  Copyright (c) 2015年 吴娅君. All rights reserved.
//

#import "PraiseAndCommentView.h"

@implementation PraiseAndCommentView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.userInteractionEnabled = YES;
        
        // 赞
        self.praiseImageView = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.praiseImageView.frame = CGRectMake(15, 10, 30, 30);
        [self.praiseImageView setBackgroundImage:[UIImage imageNamed:@"icon_great_gray_13x13@3x"] forState:(UIControlStateNormal)];
        //self.praiseImageView.backgroundColor = [UIColor brownColor];
        [self addSubview:self.praiseImageView];
        
        self.praiseLabel = [[UILabel alloc] initWithFrame:CGRectMake(47, 17, 20, 20)];
        self.praiseLabel.backgroundColor = [UIColor blackColor];
        [self addSubview:self.praiseLabel];
        
        // 评论
        self.commentImageView = [UIButton buttonWithType:(UIButtonTypeCustom)];
        //self.commentImageView.backgroundColor = [UIColor blueColor];
        self.commentImageView.frame = CGRectMake(self.praiseLabel.right + 25, self.praiseImageView.top, 30, 30);
        [self.commentImageView setBackgroundImage:[UIImage imageNamed:@"icon_comment_gray_32x32@2x"] forState:(UIControlStateNormal)];
        [self addSubview:self.commentImageView];
        
        self.commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.commentImageView.right + 2, 17, 20, 20)];
        self.commentLabel.backgroundColor = [UIColor cyanColor];
        [self addSubview:self.commentLabel];
        
    }
    return self;
}

- (void)setValueWithPraiseStr:(NSString *)praiseStr commentStr:(NSString *)commentStr
{
    self.praiseLabel.text = praiseStr;
    self.commentLabel.text = commentStr;
}

- (void)setTarget:(id)target praiseAction:(SEL)praiseAction commentAction:(SEL)commentAction index:(NSInteger)index
{
    [self.praiseImageView addTarget:target action:praiseAction forControlEvents:(UIControlEventTouchUpInside)];
    self.praiseImageView.tag = index + 10;
    [self.commentImageView addTarget:target action:commentAction forControlEvents:(UIControlEventTouchUpInside)];
    self.commentImageView.tag = index + 100;
}

@end
